<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function max(array) {
            for (var i = 0; i < array.length; i++) {
                if (array[i] > array[i + 1]) {
                    var temporary = array[i];
                    array[i] = array[i + 1];
                    array[i + 1] = temporary;
                }
            }
            return array[array.length - 1];
        }
        alert(max([2, 3, 4, 5, 6, 11, 2, 4, 46, 6665, 443]))
    </script>
</head>

<body>

</body>

</html>